Skip to content

Conversation

@trask
Copy link
Member

@trask trask commented Oct 3, 2025

Related to open-telemetry/opentelemetry-java-instrumentation#9478

Another option is to provide an API that creates the metric using these constants internally, though that doesn't help us in library instrumentation for all of the unstable metrics at least where we don't want to have a dependency on unstable semconv artifact, but we still want the constants for verification in tests.

Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very supportive of this idea! Some thoughts:

  • I think we should only generate incubating constants to start (but include stable metrics in the incubating files) to start.
  • In this proposal we generate metric name, unit description. Its still possible to misuse the conventions by choosing the wrong instrument type. Have you considered generating functions which return fully resolved metrics? I.e. something like:
public static DoubleHistogram httpServerRequestDurationMetric(Meter) { ... }

We could of course do both. Generating the name, unit, description constants is more flexible in the sense that it allows you to more easily create metrics matching a particular metric convention's name and description, but with a custom unit. I.e. http.server.request.duration with ms unit instead of the default s. But this greases the tracks to not conform to the conventions, which I'd argue we ought not to do.

@trask
Copy link
Member Author

trask commented Oct 16, 2025

I think we should only generate incubating constants to start (but include stable metrics in the incubating files) to start.

will do

@trask trask marked this pull request as ready for review October 17, 2025 15:40
@trask trask requested review from a team as code owners October 17, 2025 15:40
@trask trask closed this Oct 20, 2025
@trask trask deleted the metrics branch October 20, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants